﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class doctor_webcon_readpaper : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public int Guid
    {
        set
        {
            this.hlPaper.Attributes.Add("guid", value.ToString());
            PaperFile pf = new PaperFile(value);
            this.labDate.Text = pf.CreateTime.ToString();
            this.labIntro.Text = pf.Intro;
            this.labKeywords.Text = pf.Keywords;
            this.hlPaper.Text = pf.Title;
            this.labFlag.Text = Paper.Tip(pf.PaperFlag);
            string fn = this.hlPaper.Text + System.IO.Path.GetExtension(pf.FileName);
            this.hlPaper.NavigateUrl = Params.RootHttp + "download.aspx/" + fn + "?fp=" + Server.UrlPathEncode(Params.FilesFolderPath + pf.FileName) + "&fn=" + Server.UrlEncode(fn);
            this.StudentGuid = pf.StudentGuid;
            if (pf.IsNewest)
            {
                if (pf.PaperFlag == 3||pf.PaperFlag==5)
                {
                    this.divRead.Visible = true;
                }
            }
        }
        get
        {
            return Convert.ToInt32(this.hlPaper.Attributes["guid"]);
        }
    }

    public int StudentGuid
    {
        set
        {
            this.hlPaper.Attributes.Add("sguid", value.ToString());
        }
        get
        {
            return Convert.ToInt32(this.hlPaper.Attributes["sguid"]);
        }
    }

    protected void btnRead_Click(object sender, EventArgs e)
    {
        int f = Convert.ToInt32(this.rbStatus.SelectedValue);
        string tip = this.tbTip.Text.Trim().Replace("'","''");
        tip=(tip==""?this.rbStatus.SelectedItem.Text:tip);
        string sql = "update Paper set Flag="+f.ToString()+" where Guid="+this.Guid.ToString();
        Fun.Execute(sql);
        sql = "update Student set PaperFlag="+f.ToString()+" where UserGuid="+this.StudentGuid.ToString();
        Fun.Execute(sql);
        sql = "insert into PaperTip(Guid,Body,PaperGuid,ExpertSend) values("+Fun.Guid().ToString()+",'"+Fun.L(tip)+"',"+this.Guid.ToString()+",1)";
        Fun.Execute(sql);
        Session.Add(Params.SystemError, "发布成功！");
        Response.Redirect(Request.RawUrl);
    }
}
